package com.xsomnus.open.imv2.protocol.codec;

import com.xsomnus.open.imv2.protocol.Packet;
import com.xsomnus.open.imv2.protocol.PacketCodec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019-04-25 21:49
 * 既然选择了远方,便只顾风雨兼程
 */
public class PacketDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) {
        Packet packet = PacketCodec.INSTANCE.decode(in);
        System.out.println(packet);
        out.add(packet);
    }
}
